﻿namespace KingerRobot.MexicoSailunMDC.SpiService;
internal interface IProdProduct
{

    List<LocProductBean> GetLocProductBeans();
    /// <summary>
    /// 获得所有的产品信息
    /// </summary>
    /// <returns></returns>
    List<POProdProduct> GetProducts();
    /// <summary>
    /// 创建产品
    /// </summary>
    /// <param name="prodProductBean"></param>
    /// <returns>产品信息</returns>
    POProdProduct CreateOrUpdateProduct(ProdProductBean prodProductBean);


    string GetFilmPrductInfoBySkuId(long skuId);
    /// <summary>
    /// 修改产品信息
    /// </summary>
    /// <param name="product"></param>
    /// <returns></returns>
    int UpdateProduct(POProdProduct product);

    /// <summary>
    /// 删除产品
    /// </summary>
    /// <param name="productCode"></param>
    /// <returns></returns>
    POProdProduct DeleteProduct(string productCode);

    /// <summary>
    /// 创建产品及相关绑定数据
    /// </summary>
    /// <param name="productBindingInfoBean"></param>
    /// <returns>产品绑定信息（prod_product,prod_sku_product,prod_sku）</returns>
    ProdProductBindingBean CreateProductBindingInfo(ProductBindingInfoBean productBindingInfoBean);

    /// <summary>
    /// 创建异常产品及相关绑定数据
    /// </summary>
    /// <returns></returns>
    ProdProductBindingBean CreateAbnormalProductEmptyBinding(string productCode);
    /// <summary>
    /// 通过产品条码获取产品信息
    /// </summary>
    /// <param name="code">产品条码</param>
    /// <returns>产品信息</returns>
    POProdProduct GetProductByCode(string code);

    /// <summary>
    /// 通过产品条码集合获取产品信息
    /// </summary>
    /// <param name="codes"></param>
    /// <returns></returns>
    List<POProdProduct> GetProductByCodes(List<string> codes);

    /// <summary>
    /// 通过产品条码获取产品是否存在
    /// </summary>
    /// <param name="code">产品条码</param>
    /// <returns>true:存在；false:不存在</returns>
    bool HasProductByCode(string code);

    /// <summary>
    /// 通过产品条码获取产品绑定信息
    /// </summary>
    /// <param name="code">产品条码</param>
    /// <returns>产品绑定信息（prod_product,prod_sku_product,prod_sku）</returns>
    ProdProductBindingBean GetProductBindingInfoByCode(string code);
    /// <summary>
    /// 通过产品条码获取所有产品绑定信息
    /// </summary>
    /// <param name="codes"></param>
    /// <returns></returns>
    List<ProdProductBindingBean> GetProductBindingInfoByCodes(List<string> codes);
    /// <summary>
    /// 通过产品条码获取SkuId
    /// </summary>
    /// <param name="code">产品条码</param>
    /// <returns>SkuId</returns>
    long GetSkuIdByCode(string code);
    /// <summary>
    /// EMS取货位生成异常任务用
    /// </summary>
    /// <param name="code"></param>
    /// <returns></returns>
    long GetSkuIdByCodeEMSAbnormal(string code);

    /// <summary>
    /// 通过 SKUID 获取产品编号
    /// </summary>
    /// <param name="skuId"></param>
    /// <returns></returns>
    string GetCodeBySkuId(long skuId);
    /// <summary>
    /// 获取产品所有信息
    /// </summary>
    /// <param name="skuId"></param>
    /// <returns></returns>
    ProdProductBindingBean GetProductBindingInfoBySkuId(long skuId);

    /// <summary>
    /// 通过locId获取产品编号
    /// </summary>
    /// <param name="locId"></param>
    /// <returns></returns>
    string GetCodeByLocId(long? locId);


    /// <summary>
    /// 修改冻结
    /// </summary>
    /// <param name="productFrozenBean"></param>
    /// <returns></returns>
    int UpdateProductFrozen(ProductFrozenBean productFrozenBean);
    /// <summary>
    /// 修改产品物料
    /// </summary>
    /// <param name="barCode"></param>
    /// <param name="mateiralId"></param>
    void UpdateProductMateiralId(string barCode, long mateiralId);
    /// <summary>
    /// 获取产品
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    List<POProdProduct> GetProductByIds(List<long> ids);

    /// <summary>
    /// 根据SKU查询任务
    /// </summary>
    /// <param name="skuIds"></param>
    /// <returns></returns>
    List<ProductLocBean> GetProductIsNByLocIds(List<long> locIds);
    /// <summary>
    /// 满足条件出库胎胚可出库：质量为N；非冻结；满足最小超期时间
    /// </summary>
    /// <returns></returns>
    List<ProductLocBean> GetWarehousingOutProduct();

    int GetStockProductNum();

}


internal class ProductLocBean
{
    public long? LocId { get; set; }
    public int? GroupIndex { get; set; }
    public long? SkuId { get; set; }
    public long? MaterialId { get; set; }
    public long? CrnId { get; set; }
    public POProdSkuProduct POProdSkuProduct { get; set; }
    public POProdProduct POProdProduct { get; set; }
}
internal class ProdProductBindingBean
{
    //public POMesGreenTireBuilding POMesGreenTireBuilding { get; set; }
    public POProdProduct POProdProduct { get; set; }
    public POProdSku POProdSku { get; set; }
    public POProdSkuProduct POProdSkuProduct { get; set; }
    public POProdMaterial POProdMaterial { get; set; }
}

internal class ProdProductBean
{
    public string ProductCode { get; set; }
    public string MdEquipCode { get; set; }
    public long MaterialId { get; set; }
    public string ProductBatch { get; set; }
    public DateTime? MdTime { get; set; }
    public int? TireLock { get; set; }
    /// <summary>
    /// 质量：1:不合格0:合格
    /// </summary>
    public int? QuailtyStatus { get; set; }
    /// <summary>
    /// 超期时间
    /// </summary>
    public DateTime? ExpirationTime { get; set; }

    public long? MesId { get; set; }

}

internal class ProductBindingInfoBean
{
    /// <summary>
    /// 产品编号
    /// </summary>
    public string ProductCode { get; set; }
    /// <summary>
    /// 产品批次
    /// </summary>
    public string ProductBatch { get; set; }
    /// <summary>
    /// 物料编号
    /// </summary>
    public string MaterialCode { get; set; }
    /// <summary>
    /// 物料名
    /// </summary>
    public string MaterialName { get; set; }
    /// <summary>
    /// 有限出库
    /// </summary>
    public string Priooutyn { get; set; }
    /// <summary>
    /// 生产时间
    /// </summary>
    public DateTime? ProductTime { get; set; }
    /// <summary>
    /// 成型机code(mes传过来的)
    /// </summary>
    public string ProductEquip { get; set; }

    /// <summary>
    /// 胎胚锁定 0:解锁 1:锁定
    /// </summary>
    public int? TireLock { get; set; }

    /// <summary>
    /// 质量 0:合格 1:不合格(启用)
    /// </summary>
    public int? QualityStatus { get; set; }

    public DateTime? ExpirationTime { get; set; }

    public long? MesId { get; set; }
}

public class LocProductBean
{
    /// <summary>
    /// 库位Id
    /// </summary>
    public long? LocId { get; set; }
    /// <summary>
    /// 物料Id
    /// </summary>
    public long? MaterialId { get; set; }
    /// <summary>
    /// 物料编号
    /// </summary>
    public string MaterialCode { get; set; }
    /// <summary>
    /// 库位占用
    /// </summary>
    public int? LocTaskOccupy { get; set; }
    /// <summary>
    /// 出库可用性
    /// </summary>

    public int? LocOutEnable { get; set; }
    /// <summary>
    /// 库位可用性
    /// </summary>
    public int? LocEnable { get; set; }
    /// <summary>
    /// 胎胚锁定
    /// </summary>
    public int? TireLoc { get; set; }
    /// <summary>
    /// 有货时间
    /// </summary>
    public DateTime? LocHasSkuTime { get; set; }
    /// <summary>
    /// 生产时间
    /// </summary>
    public DateTime? MdTime { get; set; }
    /// <summary>
    /// 库位组号
    /// </summary>
    public long? LocGroupId { get; set; }
    /// <summary>
    /// 组顺序
    /// </summary>
    public int? LocGroupIndex { get; set; }
    /// <summary>
    /// 产品Id
    /// </summary>
    public long? ProductId { get; set; }
}